<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCouponCodesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('coupon_codes', function (Blueprint $table) {
            $table->increments('id');
            $table->string('code')->unique()->comment('卡密');
            $table->integer('validity_time')->comment('有效期');
            $table->dateTime('exchange_end_time')->comment('兑换截止日期');
            $table->integer('coupon_type_id')->comment('类型ID');
            $table->dateTime('use_time')->nullable()->comment('核销时间');
            $table->tinyInteger('used_system')->default(0)->comment('对接系统[0. 暂未对接, 1. 积分,   2. cps]');
            $table->timestamps();
        });

        \DB::statement("ALTER TABLE `coupon_codes` comment '优惠券'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('coupon_codes');
    }
}
